package com.example.supernote.ui.note.components

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.example.supernote.R
import com.example.supernote.ui.components.UniformDialog

@Composable
fun ShowLinkDialog(
    onCancel: () -> Unit,
    onConfirm: (String, String) -> Unit
) {
    var name by remember { mutableStateOf("") }
    var link by remember { mutableStateOf("") }
    UniformDialog(
        title = stringResource(R.string.note_add_link),
        onCancel = onCancel,
        onConfirm = { onConfirm(name, link) },
        body = {
            TextField(
                value = name,
                modifier = Modifier
                    .padding(end = 5.dp)
                    .fillMaxWidth(),
                onValueChange = { name = it },
                singleLine = true,
                label = {
                    Text(
                        text = stringResource(R.string.note_link_name),
                        color = Color.Gray,
                        overflow = TextOverflow.Visible
                    )
                }
            )
            TextField(
                value = link,
                modifier = Modifier
                    .padding(end = 5.dp)
                    .fillMaxWidth(),
                onValueChange = { link = it },
                singleLine = true,
                label = {
                    Text(
                        text = "https://www.example.com",
                        color = Color.Gray,
                        overflow = TextOverflow.Visible
                    )
                }
            )
        }
    )
}